package com.example.lt.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.lt.mapper.AdminMapper;
import com.example.lt.pojo.dto.AdminLoginDTO;
import com.example.lt.pojo.entity.Admin;
import com.example.lt.pojo.vo.AdminVO;
import com.example.lt.result.Result;
import com.example.lt.service.AdminService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 小涛Tao
 * @Date: 2024/06/11/18:57
 * version 1.0 注释：
 **/
@Service
@RequiredArgsConstructor
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    private final AdminMapper adminMapper;

    /**
     * 管理员登录，获取管理员信息
     * @param adminLoginDTO
     * @return
     */
    public Admin adminLogin(AdminLoginDTO adminLoginDTO) {
        List<Admin> adminList = lambdaQuery()
                .eq(Admin::getName, adminLoginDTO.getUsername())
                .eq(Admin::getPassword, adminLoginDTO.getPassword())
                .list();

        if (adminList.size() > 0) {
            return adminList.get(0); // 查询到了就返回该管理员的信息
        } else {
            return null; // 没有查到就返回空
        }
    }

}
